package com.woniu.smallmedical.controller;

import com.woniu.smallmedical.entity.*;
import com.woniu.smallmedical.server.GraphInfoServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author author
 * @create 2021-10-08-14:04
 */
@CrossOrigin
@RestController
public class GraphInfoController {
    @Autowired
    GraphInfoServer graphInfoServer;
    @RequestMapping("/getPatientGender")
    /**
     * 图形统计根据患者性别分析
     */
    public ResponseResult getPatientGender(DateStartEnd dateStartEnd){
        List<GraphInfo> graphInfos = graphInfoServer.GetCountGrapInfoGender(dateStartEnd);
        return new ResponseResult(graphInfos,200,"success");
    }
    /**
    * 图形统计根据患者年龄段分析
    */
    @RequestMapping("/getPatientAge")
    public ResponseResult getPatientAge(DateStartEnd dateStartEnd){
        List<GraphInfo> countGrapInfoAge = graphInfoServer.getCountGrapInfoAge(dateStartEnd);
        return new ResponseResult(countGrapInfoAge,200,"success");
    }
    /**
     * 统计今日挂号人次，今日接诊人次，今日收入
     */
    @RequestMapping("/getOperationCount")
    public ResponseResult getOperationCount(DateStartEnd dateStartEnd){
        int countRegistration = graphInfoServer.getCountRegistration(dateStartEnd);
        int countPatient = graphInfoServer.getCountPatient(dateStartEnd);
        CountInfo countInfo=new CountInfo();
        countInfo.setRegistrationCount(countRegistration);
        countInfo.setClinicalCount(countPatient);
        return new ResponseResult(countInfo,200,"success");
    }
    @RequestMapping("/getClincLog")
    public ResponseResult getClincLog(DateStartEnd dateStartEnd,Integer pageIndex,Integer pageSize){
        System.out.println(dateStartEnd);
        PageBean<ClincLog> clincLog = graphInfoServer.getClincLog(dateStartEnd,pageIndex,pageSize);
        return new ResponseResult(clincLog,200,"success");
    }
    @RequestMapping("/getDoctor")
    public ResponseResult getFormNav(){
        List<User> doctors = graphInfoServer.getDoctor();
        return new ResponseResult(doctors,200,"success");
    }

    @RequestMapping("/getFolw")
    public ResponseResult getFolw(){
        List<Flow> flow = graphInfoServer.getFlow();
        return new ResponseResult(flow,200,"success");
    }


}
